package com.ktgj.flight.controller;

import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.flight.common.huaxia.G5Service;
import com.ktgj.flight.domain.InterfaceEntity.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@ControllerAdvice
@RestController
@RequestMapping("/G5")
public class G5Controller {
    @Autowired
    private G5Service g5Service;

    /**
     * 航班查询
     * @param request
     * @return
     */
    @PostMapping("/flightSearch")
    public AjaxResult flightSearch(@RequestBody MoFlightSearchRequest request) {
        MoFlightSearchResponse response = g5Service.flightSearch(request);
        return AjaxResult.success(response);
    }

    /**
     * 航班预定
     * @param request
     * @return
     */
    @PostMapping("/orderCreate")
    public AjaxResult orderCreate(@RequestBody MoCreateOrderRequest request) {
        MoCreateOrderResponse response = g5Service.orderCreate(request);
        return AjaxResult.success(response);
    }

    /**
     * 查询订单详情
     * @param request
     * @return
     */
    @PostMapping("/queryOrderInfo")
    public AjaxResult queryOrderInfo(@RequestBody MoQueryOrderRequest request) {
        MoQueryOrderResponse response = g5Service.queryOrderInfo(request);
        return AjaxResult.success(response);
    }

    /**
     * 订单支付
     * @param request
     * @return
     */
    @PostMapping("/orderPayment")
    public AjaxResult orderPayment(@RequestBody MoYeePayRequest request) {
        MoOrderPayResponse response = g5Service.orderPayment(request);
        return AjaxResult.success(response);
    }

    /**
     * 出票
     * @param request
     * @return
     */
    @PostMapping("/orderPay")
    public AjaxResult orderPay(@RequestBody MoOrderPayRequest request) {
        MoOrderPayResponse response = g5Service.orderPay(request);
        return AjaxResult.success(response);
    }

    /**
     * 查询退票手续费
     * @param request
     * @return
     */
    @PostMapping("/orderRefundCalt")
    public AjaxResult orderRefundCalt(@RequestBody MoOrderRefundCaltRequest request) {
        MoOrderRefundCaltResponse response = g5Service.orderRefundCalt(request);
        return AjaxResult.success(response);
    }

    /**
     * 申请退票
     * @param request
     * @return
     */
    @PostMapping("/orderRefund")
    public AjaxResult orderRefund(@RequestBody MoOrderRefundRequest request) {
        MoOrderRefundResponse response = g5Service.orderRefund(request);
        return AjaxResult.success(response);
    }
}
